package com.lg.happyfarmer.activity;

import android.app.ActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.lg.happyfarmer.R;
import com.lg.happyfarmer.base.BaseActivity;
import com.lg.happyfarmer.base.BaseUtil;
import com.lg.happyfarmer.snackbar.BaseTransientBottomBar;
import com.lg.happyfarmer.snackbar.TopSnackBar;
import com.lg.happyfarmer.untils.UserUtils;

import butterknife.Bind;
import butterknife.ButterKnife;
import xtom.frame.XtomActivityManager;

/**
 * 权限页面
 * Created by Torres on 2018/3/31 0031.
 */

public class RightActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.ib_back)
    ImageButton ib_back;
    @Bind(R.id.btn_test)
    Button btn_test;
    @Bind(R.id.title_right_btn)
    Button title_right_btn;

    @Bind(R.id.iv_right)
    ImageView iv_right;
    @Bind(R.id.iv_loc)
    ImageView iv_loc;
    private int right = 0;//1 选中 0 未选中
    private int loc = 0;//1 选中 0 未选中
    private String temp;
    @Bind(R.id.ll_all)
    LinearLayout ll_all;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_right);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
        BaseUtil.startLayoutAnim(mContext, ll_all);
    }

    @Override
    protected void callBeforeDataBack(HemaNetTask netTask) {
        super.callBeforeDataBack(netTask);
    }

    @Override
    protected void callAfterDataBack(HemaNetTask netTask) {
        super.callAfterDataBack(netTask);
    }

    @Override
    protected void callBackForServerSuccess(HemaNetTask netTask, HemaBaseResult baseResult) {
        super.callBackForServerSuccess(netTask, baseResult);
    }

    @Override
    protected void callBackForServerFailed(HemaNetTask netTask, HemaBaseResult baseResult) {
        super.callBackForServerFailed(netTask, baseResult);
    }

    @Override
    protected void callBackForGetDataFailed(HemaNetTask netTask, int failedType) {
        super.callBackForGetDataFailed(netTask, failedType);
    }

    @Override
    protected void findView() {
        ib_back.setVisibility(View.INVISIBLE);
    }

    @Override
    protected void getExras() {
        super.getExras();
    }

    @Override
    protected void setListener() {
        super.setListener();
        btn_test.setEnabled(true);
        btn_test.setOnClickListener(this);
        ib_back.setOnClickListener(this);
        iv_loc.setOnClickListener(this);
        iv_right.setOnClickListener(this);
        title_right_btn.setText("跳过");
        title_right_btn.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {

        Intent it = null;
        switch (view.getId()) {
            case R.id.title_right_btn:
                it = new Intent(mContext, WelcomeActivity.class);
                startActivity(it);
                break;
            case R.id.ib_back:
                finish();
                break;
            case R.id.iv_loc:
                if (loc == 0) {
                    iv_loc.setImageResource(R.mipmap.icon_correct);
                    loc = 1;
                } else {
                    iv_loc.setImageResource(R.mipmap.icon_nochoice);
                    loc = 0;
                }

                break;
            case R.id.iv_right:
                if (right == 0) {
                    iv_right.setImageResource(R.mipmap.icon_correct);
                    right = 1;
                } else {
                    iv_right.setImageResource(R.mipmap.icon_nochoice);
                    right = 0;
                }
                break;
            case R.id.btn_test:
                it = new Intent(mContext, WelcomeActivity.class);
                startActivity(it);
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            XtomActivityManager.finishAll();
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
